package com.example.demo.controller;

import com.example.demo.models.Test;
import com.example.demo.service.ITestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @author Liunh
 */
@RestController
@RequestMapping(value = "/test")
public class TestController {

    @Autowired
    private ITestService testService;

    @PostMapping(value = "/add")
    public ResponseEntity add(@RequestBody Test req) {
        return new ResponseEntity<>(testService.insert(req), HttpStatus.OK);
    }

    @PostMapping(value = "/update")
    public ResponseEntity update(@RequestBody Test req) {
        return new ResponseEntity<>(testService.update(req), HttpStatus.OK);
    }

    @PostMapping(value = "/findList")
    public ResponseEntity findList(Test req) {
        return new ResponseEntity<>(testService.findList(req), HttpStatus.OK);
    }


    @GetMapping(value = "/delete/{id}")
    public ResponseEntity delete(@PathVariable(value = "id") Integer id) {
        return new ResponseEntity<>(testService.delete(id), HttpStatus.OK);
    }

}